package com.ruoyi.common.utils.sms;

import com.ruoyi.project.WxMoudle.Bases.HttpUtil;
import com.ruoyi.project.WxMoudle.Bases.WeixinConfig;

import java.net.URLEncoder;

/**
 * @Description短信发送
 * @Author flp
 * @Date 2020/5/8 10:15
 */
public class SmsSendUtil {

    public static String  toSendSms(String templateid, String phoneNum) throws Exception{
        StringBuilder sb = new StringBuilder();
        sb.append("accountSid").append("=").append(WeixinConfig.ACCOUNT_SID);
        sb.append("&to").append("=").append(phoneNum);
        sb.append("&param").append("=").append(URLEncoder.encode("","UTF-8"));
        sb.append("&templateid").append("=").append(templateid);
        String body = sb.toString() + HttpUtil.createCommonParam(WeixinConfig.ACCOUNT_SID, WeixinConfig.AUTH_TOKEN);
        String result = HttpUtil.post(WeixinConfig.BASE_URL, body);
        return result;
    }
}
